﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartWMS.Common.Extensions;
using SmartWMS.Common.ResponseOutput;
using SmartWMS.Domain.WarehouseManage;
using SmartWMS.EntityFramework;
using SmartWMS.Server.WarehouseManage.CheckServer.Dto;
using SmartWMS.Server.WarehouseManage.InventoryLedgerServer;
using SmartWMS.Server.WarehouseManage.InventoryLedgerServer.Dto;

namespace SmartWMS.API.Controllers.WarehouseManage
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [ApiExplorerSettings(GroupName = "Warehouse")]
    public class ChecksController : ControllerBase
    {

        private readonly ICheckServers checkServers;

        public ChecksController(ICheckServers checkServers)
        {
            this.checkServers = checkServers;
        }



        /// <summary>
        /// 盘点列表
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<List<CheckDtoPes>>> GetCheckDtoPes(CheckDtoPage dto)
        {
            var list = await checkServers.GetCheckDtoPes(dto);
            return list;
        }

        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<bool>> DelCheck(CheckDtoPage dto)
        {
            var result = await checkServers.DelCheck(dto);
            return result;
        }

        /// <summary>
        /// 批量删除数据（盘点表盘点明细）
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<bool>> DeleteBatchCheck(List<CheckDtoPage> dto)
        {
            var result = await checkServers.DeleteBatchCheck(dto);
            return result;
        }
        /// <summary>
        /// 添加盘点数据（盘点明细）
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<bool>> AddCheck(CheckDtoPes dto)
        {
            var result = await checkServers.AddCheck(dto);
            return result;
        }
        /// <summary>
        /// 反填数据
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public CheckDtoPes ReckCheck(CheckDtoPes dto)
        {
            var list = checkServers.ReckCheck(dto);
            return list;
        }
        /// <summary>
        /// 修改单条数据
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<bool>> UpdateCheckDetail(ProduDtoPes dto)
        {
            var result = await checkServers.UpdateCheckDetail(dto);
            return result;
        }
        /// <summary>
        /// 批量修改数据
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<bool>> UpdateCheck(CheckDtoPes dto)
        {
            var resulkt = await checkServers.UpdateCheck(dto);
            return resulkt;
        }

        /// <summary>
        /// 订单审核
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<bool>> UpdateCheckState(CheckDtoPes dto)
        {
            var result = await checkServers.UpdateCheckState(dto);
            return result;
        }

    }
}
